package com.cuje.coolrtc.utils;

import java.util.Random;

public class CommonUtil {

    private static final String RANDOM_STRING_TEMPLE = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ";

    public static String randomString(int len) {
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        int _len = RANDOM_STRING_TEMPLE.length();
        for (int j = 0; j < len; j++) {
            int index = random.nextInt(_len);
            char c = RANDOM_STRING_TEMPLE.charAt(index);
            sb.append(c);
        }
        return sb.toString();
    }

    public static String randomString(int startLen, int endLen) {
        return randomString(startLen + new Random().nextInt(endLen - startLen));
    }

}
